package cn.itsource.ldj.user.controller;

import cn.itsource.ldj.user.service.IWxUserService;
import cn.itsource.ldj.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/wechat")
public class WxUserController {

    @Autowired
    private IWxUserService wxUserService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody Map<String,Object> map){

        return wxUserService.login(map);
    }

    @PostMapping("/bind")
    public AjaxResult bind(@RequestBody Map<String, String> map) {
        try {
            return wxUserService.bind(map);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMsg(e.getMessage());
        }
    }
}
